package com.cetool.autocms.controller.tradesequence;

import com.cetool.autocms.annotation.TokenAnnotation;
import com.cetool.autocms.common.PageRequest;
import com.cetool.autocms.enumeration.OperateEnum;
import com.cetool.autocms.pojo.dto.tradesequence.TradeSequenceInfoDTO;
import com.cetool.autocms.pojo.request.tradesequence.DeleteTradeSequenceRequest;
import com.cetool.autocms.pojo.request.tradesequence.QueryTradeSequenceListRequest;
import com.cetool.autocms.pojo.request.tradesequence.SaveTradeSequenceRequest;
import com.cetool.autocms.pojo.request.tradesequence.UpdateTradeSequenceRequest;
import com.cetool.autocms.service.tradesequence.TransactionSerialService;
import com.github.pagehelper.PageSerializable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 交易序列管理控制层
 *
 * @author 戴越
 * @date 2021/11/10
 */
@RestController
@RequestMapping("/transSerial")
@Api(tags = "交易序列管理")
public class TradeSequenceController {
    /**
     * 注入交易序列管理服务
     */
    @Autowired
    private TransactionSerialService transactionSerialService;

    /**
     * 分页查询交易序列列表
     *
     * @param request 分页查询交易序列请求实体
     * @return 交易序列信息分页列表
     * @author 戴越
     * @date 2021/11/12
     */
    @TokenAnnotation
    @PostMapping("/listPageTradeSequence")
    @ApiOperation(value = "分页查询交易序列列表")
    public PageSerializable<TradeSequenceInfoDTO> listPageTradeSequence(@RequestBody PageRequest<QueryTradeSequenceListRequest> request) {
        return transactionSerialService.listPageTradeSequence(request);
    }

    /**
     * 新增交易序列
     *
     * @param request 新增交易序列请求实体
     * @return 操作信息
     * @author 戴越
     * @date 2021/11/12
     */
    @TokenAnnotation
    @PostMapping("/saveTradeSequence")
    @ApiOperation(value = "新增交易序列")
    public OperateEnum saveTradeSequence(@Valid @RequestBody SaveTradeSequenceRequest request) {
        return transactionSerialService.saveTradeSequence(request);
    }

    /**
     * 删除交易序列
     *
     * @param request 删除交易序列请求实体
     * @return 操作信息
     * @author 戴越
     * @date 2021/11/12
     */
    @TokenAnnotation
    @PostMapping("/deleteTradeSequence")
    @ApiOperation(value = "删除交易序列")
    public OperateEnum deleteTradeSequence(@Valid @RequestBody DeleteTradeSequenceRequest request) {
        return transactionSerialService.deleteTradeSequence(request);
    }

    /**
     * 修改交易序列
     *
     * @param request 修改交易序列请求实体
     * @return 操作信息
     * @author 戴越
     * @date 2021/11/12
     */
    @TokenAnnotation
    @PostMapping("/updateTradeSequence")
    @ApiOperation(value = "修改交易序列")
    public OperateEnum updateTradeSequence(@Valid @RequestBody UpdateTradeSequenceRequest request) {
        return transactionSerialService.updateTradeSequence(request);
    }

}
